package com.ht.utils.htmlBean;

import com.ht.utils.config.WordAndHtmlConfig;
import lombok.Data;

@Data
public class RPR {

    private String fontFamily;
    private String fontSize;
    private String fontWeight;
    private String fontStyle;
    private String fontColor;
    private String content;
    private String highlight;
    private boolean isBold = false;
    private boolean isXiaHua = false;
    private boolean isXieTi = false;
    private boolean isShanChu = false;
    private int type = 0;
    private String imgWidth;
    private String imgHeight;
    private String imgPath;

    public void setFontSize(String fontSize) {
        double temp = Double.parseDouble(fontSize);
        this.fontSize = temp + "";
    }

    String toHtml(){
        StringBuilder html = new StringBuilder();
        switch (this.type){
            case 0:
                html.append("<span style=\"");
                if(fontFamily != null){
                    html.append(" font-family:'").append(WordAndHtmlConfig.getZiTiByWord(fontFamily)).append("'; ");
                }
                if(fontColor != null){
                    html.append(" color:#").append(fontColor).append("; ");
                }
                if(fontSize != null){
                    html.append(" font-size: ").append(fontSize).append("px; ");
                }
                if(highlight != null){
                    html.append(" background-color: ").append(highlight).append("; ");
                }
                if(isBold){
                    html.append(" font-weight:bold; ");
                }
                if(isShanChu){
                    html.append(" text-decoration:line-through; ");
                }
                if(isXiaHua){
                    html.append(" text-decoration:underline; ");
                }
                if(isXieTi){
                    html.append(" font-style:italic; ");
                }
                html.append(" \" >").append(content).append("</span>");
                break;
            case 1:
                html.append("<img src=\"").append(this.imgPath).append("\" style=\"\" width='")
                        .append(this.imgWidth).append("' height='").append(this.imgHeight).append("'/>");
                break;
        }
        return html.toString();
    }

}
